from openai import OpenAI
import requests
import dotenv
import os

dotenv.load_dotenv()
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"), base_url=os.getenv("BASE_URL"))

response = client.images.generate(
    model=os.getenv("MODEL_NAME"),
    prompt="一位白衣少年,站在黄土高坡上,数字艺术风格,高清",
    size="1024x1024",
    quality="standard",
    n=1
)

image_url = response.data[0].url
image_data = requests.get(image_url).content
with open("generated_image.png", "wb") as f:
    f.write(image_data)